const util = require('../../../utils/util')
const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter
const oss_domain = getApp().globalData.oss_domain
const status_list = getApp().globalData.status_list
const status_bgColors = getApp().globalData.status_bgColors
const license_list = getApp().globalData.license_list
const pilot_rank_list = getApp().globalData.pilot_rank_list
const user_id = wx.getStorageSync('user_id')
const right_list = ['is_admin',1,2,3,4]
const today = util.formatDate(new Date())
// pages/students/passing_rate/passing_rate.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    today,
    right_list,
    pilot_rank_list,
    license_list,
    user_id,
    status_bgColors,
    status_list,
    stu_name:'',
    loading:true,
    icon_url:oss_domain + 'static/picture/app_icon/',
  },


  view_stu(e){
    let jg_stu_id = e.currentTarget.id
    getApp().get_vibration()
    wx.navigateTo({
      url: '/pages/students/stu_register/stuRegister_info/stuRegister_info?jg_stu_id=' + jg_stu_id
    })
  },

  
  test_stage(e){
    getApp().get_vibration()
    let index1 = e.currentTarget.dataset.index1
    let stage_id = this.data.stu.test_stages[index1].id
    let jg_stu_id = this.data.jg_stu_id
    let name = this.data.stu.name
    if(stage_id==1){
      var url_data = {jg_stu_id,stu_name:name,chap_id_list:[1,2,3,4,5,6,7,8,9]}
      var url = '/pages/students/stu_chapters/stu_chapters?url_data=' + encodeURIComponent(JSON.stringify(url_data))
    }else if(stage_id==2){
      var url_data = {jg_stu_id,stu_name:name,chap_id_list:[17]}
      var url = '/pages/students/stu_chapters/stu_chapters?url_data=' + encodeURIComponent(JSON.stringify(url_data))
    }else{
      var url_data = {
        jg_id : this.data.jg_id,
        jg_stu_id : jg_stu_id,
        stage_id : stage_id,
      }
      var url = '/pages/students/process_of_stage/process_of_stage?url_data=' + encodeURIComponent(JSON.stringify(url_data))
    }
    wx.navigateTo({url})
    this.can_onShow = true
  },



  page_init(jg_stu_id){
    wx.request({
      url: domainName + 'my_trainings_init',
      data: {jg_stu_id},...parameter,
      success: res => {
        wx.hideLoading()
        console.log('res',res.data)
        this.setData({
          stu:res.data.stu,
          loading:false,
        })
      },
    })
  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log('options',options)
    this.data.jg_stu_id = options.jg_stu_id
    this.data.jg_id = options.jg_id
    wx.showLoading()
    this.page_init(this.data.jg_stu_id)
  },




})